package leetcode;

public class DiffAlphabetCount {

	public static void main(String[] args) {

		System.out.println(numDistinct("b", "a"));
	}

	public static int numDistinct(String S, String T) {
		if (S == null || T == null) {
			return -1;
		}
		int length1 = S.length();
		int length2 = T.length();
		if (length1 == 0 || length2 == 0) {
			return length1 == 0 ? 0 : length1;
		}
		int[] dp = new int[S.length()];
		int minLength = Math.min(length1, length2), difLength = Math
				.abs(length1 - length2);
		dp[0] = S.charAt(0) == T.charAt(0) ? 0 : 1;
		for (int i = 1; i < minLength; i++) {
			dp[i] = dp[i - 1] + (S.charAt(i) == T.charAt(i) ? 0 : 1);
		}
		dp[minLength - 1] += difLength;
		return dp[minLength - 1];
	}
}
